const {resolve} = require("path");
//html编译
const HtmlWebpackPlugin = require("html-webpack-plugin")
module.exports = {
    mode:"development",
    entry:"./src/index.js",
    output:{
        filename:"js/bundle.js",
        path:resolve(__dirname,"build")
    },
    module:{
        rules:[
            {
                test:/\.js$/,
                exclude:/node_modules/,
               
                //js基本兼容性问题 babel-loader @babel/core
                // 1.  基本语法转换 @babel/preset-env
                // 2.全部兼容性问题  @babel/ployfill 在入口文件引入即可
                // 3.按需加载 core-js
                use:[
                    {
                        loader:"babel-loader",
                        options:{
                            presets:[
                                //里面也是数组
                                [
                                    '@babel/preset-env',
                                    {
                                        useBuiltIns:'usage',
                                        corejs:{
                                        //core-js的版本
                                            version:3
                                        },
                                        //需要兼容的浏览器
                                        targets:{
                                            chrome:'60',
                                            firefox:'60',
                                            ie:'9',
                                            safari:'10',
                                            edge:'17'
                                        }
                                    }
                                ]
                            ]
                                
                        } 
                    }
                ]
                
            }  
        ]
    },
    plugins:[
        new HtmlWebpackPlugin()
    ]

}